home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / DELPHI.SWG / 0026_Get the windows and DOS versions.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  927 b   |  33 lines

  1. {
  2. Q:  How can I get the Windows or DOS version numbers?
  3.  
  4. A:  The API call GetVersion will do it, but the information is
  5. encrypted into a longint.  Here is how to get and decrypt the information:
  6. }
  7.  
  8.   Type
  9.     TGetVer = record
  10.       WinVer,
  11.       WinRev,
  12.       DosRev,
  13.       DosVer: Byte;
  14.     end;
  15.  
  16.   const
  17.     VerStr = '%d.%d';
  18.  
  19.   procedure TForm1.Button1Click(Sender: TObject);
  20.   var
  21.     AllVersions: TGetVer;
  22.   begin
  23.     AllVersions := TGetVer(GetVersion);
  24.     Edit1.Text := Format(VerStr, [AllVersions.WinVer, AllVersions.WinRev]);
  25.     Edit2.Text := Format(VerStr, [AllVersions.DOSVer, AllVersions.DOSRev]);
  26.   end;
  27.  
  28. Note1:  The values that windows displays for the versions and the values
  29. that it returns through its API call are not always the same.  e.g.  The
  30. workgroup version displays as 3.10 rather than 3.11.
  31.  
  32. Note2: Win32 applications should call GetVersionEx rather than GetVersion.
  33.